{% unless grid_item_width %}
  {% assign grid_item_width = 'large--one-third medium--one-half' %}
{% endunless %}

{% unless current_collection %}
  {% assign current_collection = collection %}
{% endunless %}

{% assign on_sale = false %}
{% if item.compare_at_price > item.price %}
  {% assign on_sale = true %}
{% endif %}

{% assign sold_out = true %}
{% if item.available %}
  {% assign sold_out = false %}
{% endif %}

{% assign image_size = settings.collection_prod_image_sizes %}

<div class="grid-item search-result {{ grid_item_width }}{% if sold_out %} sold-out{% endif %}{% if on_sale %} on-sale{% endif %}">

  <a href="{{ item.url | within: current_collection }}" class="product-grid-item">

    {% if item.featured_image %}
      <div class="product-grid-image">
        <div class="product-grid-image--centered">
          {% if sold_out %}
            <div class="badge badge--sold-out"><span class="badge-label">{{ 'products.product.sold_out' | t }}</span></div>
          {% endif %}
          <img src="{{ item.featured_image.src | img_url: image_size }}" alt="{{ item.featured_image.alt | escape }}">
        </div>
      </div>

      <p>{{ item.title }}</p>

      <div class="product-item--price">
        <span class="h1 medium--left">
          {% include 'price' with item.price %}
        </span>

        {% if on_sale %}
          <span class="sale-tag medium--right">
            {% assign compare_price = item.compare_at_price %}
            {% assign product_price = item.price %}
            {% include 'price-sale' %}
          </span>
        {% endif %}
      </div>
    {% else %}
      {% assign img_tag = '<' | append: 'img' %}
      {% if item.content contains img_tag %}
        {% assign src = item.content | split: 'src="' %}
        {% assign src = src[1] | split: '"' | first %}
        {% if src %}
          {% assign image_src = src | replace: '_small.', '.' | replace: '_compact.', '.' | replace: '_medium.', '.' | replace: '_large.', '.' | replace: '_grande.', '.' %}
          {{ image_src | img_tag }}
        {% endif %}
      {% endif %}

      <div class="product-grid-image">
        <div class="product-grid-image--centered">
          {{ image_src | img_tag }}
        </div>
      </div>

      <p class="h6">{{ item.title }}</p>

      <div class="rte">
        {% if item.excerpt.size > 0 %}
          {{ item.excerpt }}
        {% else %}
          <p>{{ item.content | strip_html | truncatewords: 30 }}</p>
        {% endif %}
      </div>
    {% endif %}


  </a>

</div>
